.class public Lrexsee/network/SocketServer;
.super Ljava/lang/Thread;
.source "SocketServer.java"


# instance fields
.field private final mBacklog:I

.field private final mLocalInetSocketAddress:Ljava/net/InetSocketAddress;

.field private mOnConnected:Lrexsee/network/SocketAbstractClass$SocketConnectedListener;

.field private mOnFailed:Lrexsee/network/SocketAbstractClass$SocketFailedListener;

.field private mOnLost:Lrexsee/network/SocketAbstractClass$SocketLostListener;

.field private mOnRead:Lrexsee/network/SocketAbstractClass$SocketDataListener;

.field private mOnStarted:Lrexsee/network/SocketAbstractClass$SocketStartedListener;

.field private mOnWrite:Lrexsee/network/SocketAbstractClass$SocketDataListener;

.field private final mReadingCycle:I

.field private mReadingThreads:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/Long;",
            "Ljava/lang/Thread;",
            ">;"
        }
    .end annotation
.end field

.field private final mServerId:Ljava/lang/String;

.field private mServerSocket:Ljava/net/ServerSocket;

.field private mSockets:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Ljava/lang/Long;",
            "Ljava/net/Socket;",
            ">;"
        }
    .end annotation
.end field

.field private final mTimeout:I


# direct methods
.method public constructor <init>(Ljava/lang/String;Ljava/net/InetSocketAddress;III)V
    .locals 1
    .param p1, "serverId"    # Ljava/lang/String;
    .param p2, "localInetSocketAddress"    # Ljava/net/InetSocketAddress;
    .param p3, "backlog"    # I
    .param p4, "timeout"    # I
    .param p5, "readingCycle"    # I

    .prologue
    const/4 v0, 0x0

    .line 38
    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    .line 30
    iput-object v0, p0, Lrexsee/network/SocketServer;->mOnLost:Lrexsee/network/SocketAbstractClass$SocketLostListener;

    .line 31
    iput-object v0, p0, Lrexsee/network/SocketServer;->mOnRead:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    .line 32
    iput-object v0, p0, Lrexsee/network/SocketServer;->mOnWrite:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    .line 39
    iput-object p1, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    .line 40
    iput-object p2, p0, Lrexsee/network/SocketServer;->mLocalInetSocketAddress:Ljava/net/InetSocketAddress;

    .line 41
    iput p3, p0, Lrexsee/network/SocketServer;->mBacklog:I

    .line 42
    iput p4, p0, Lrexsee/network/SocketServer;->mTimeout:I

    .line 43
    iput p5, p0, Lrexsee/network/SocketServer;->mReadingCycle:I

    .line 44
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    .line 45
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    .line 46
    return-void
.end method

.method static synthetic access$0(Lrexsee/network/SocketServer;)I
    .locals 1

    .prologue
    .line 26
    iget v0, p0, Lrexsee/network/SocketServer;->mReadingCycle:I

    return v0
.end method

.method static synthetic access$1(Lrexsee/network/SocketServer;)Lrexsee/network/SocketAbstractClass$SocketDataListener;
    .locals 1

    .prologue
    .line 31
    iget-object v0, p0, Lrexsee/network/SocketServer;->mOnRead:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    return-object v0
.end method

.method static synthetic access$2(Lrexsee/network/SocketServer;)Ljava/lang/String;
    .locals 1

    .prologue
    .line 22
    iget-object v0, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$3(Lrexsee/network/SocketServer;)Lrexsee/network/SocketAbstractClass$SocketLostListener;
    .locals 1

    .prologue
    .line 30
    iget-object v0, p0, Lrexsee/network/SocketServer;->mOnLost:Lrexsee/network/SocketAbstractClass$SocketLostListener;

    return-object v0
.end method


# virtual methods
.method public close()V
    .locals 2

    .prologue
    const/4 v1, 0x0

    .line 140
    iput-object v1, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    .line 141
    iput-object v1, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    .line 143
    :try_start_0
    iget-object v0, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    invoke-virtual {v0}, Ljava/net/ServerSocket;->close()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 146
    :goto_0
    iput-object v1, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    .line 147
    return-void

    .line 144
    :catch_0
    move-exception v0

    goto :goto_0
.end method

.method public close(J)V
    .locals 4
    .param p1, "index"    # J

    .prologue
    .line 208
    iget-object v2, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/Thread;

    .line 209
    .local v1, "thread":Ljava/lang/Thread;
    if-eqz v1, :cond_0

    .line 211
    const/4 v1, 0x0

    .line 212
    :try_start_0
    iget-object v2, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    .line 216
    :cond_0
    :goto_0
    iget-object v2, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/net/Socket;

    .line 217
    .local v0, "socket":Ljava/net/Socket;
    if-eqz v0, :cond_1

    .line 219
    :try_start_1
    invoke-virtual {v0}, Ljava/net/Socket;->close()V

    .line 220
    const/4 v0, 0x0

    .line 221
    iget-object v2, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 225
    :cond_1
    :goto_1
    return-void

    .line 222
    :catch_0
    move-exception v2

    goto :goto_1

    .line 213
    .end local v0    # "socket":Ljava/net/Socket;
    :catch_1
    move-exception v2

    goto :goto_0
.end method

.method public contains(J)Z
    .locals 2
    .param p1, "index"    # J

    .prologue
    .line 156
    iget-object v0, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/util/HashMap;->containsKey(Ljava/lang/Object;)Z

    move-result v0

    return v0
.end method

.method public count()I
    .locals 1

    .prologue
    .line 150
    iget-object v0, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->size()I

    move-result v0

    return v0
.end method

.method public getBacklog()I
    .locals 1

    .prologue
    .line 134
    iget v0, p0, Lrexsee/network/SocketServer;->mBacklog:I

    return v0
.end method

.method public getLocalInetSocketAddress()Ljava/net/InetSocketAddress;
    .locals 1

    .prologue
    .line 131
    iget-object v0, p0, Lrexsee/network/SocketServer;->mLocalInetSocketAddress:Ljava/net/InetSocketAddress;

    return-object v0
.end method

.method public getServerId()Ljava/lang/String;
    .locals 1

    .prologue
    .line 122
    iget-object v0, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    return-object v0
.end method

.method public getServerSocket()Ljava/net/ServerSocket;
    .locals 1

    .prologue
    .line 125
    iget-object v0, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    return-object v0
.end method

.method public getSocket(J)Ljava/net/Socket;
    .locals 2
    .param p1, "index"    # J

    .prologue
    .line 128
    iget-object v0, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object p0

    .end local p0    # "this":Lrexsee/network/SocketServer;
    check-cast p0, Ljava/net/Socket;

    return-object p0
.end method

.method public getSockets()Ljava/lang/String;
    .locals 1

    .prologue
    .line 153
    iget-object v0, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-virtual {v0}, Ljava/util/HashMap;->keySet()Ljava/util/Set;

    move-result-object v0

    invoke-static {v0}, Lrexsee/core/utilities/Json;->toJson(Ljava/util/Set;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getTimeout()I
    .locals 1

    .prologue
    .line 137
    iget v0, p0, Lrexsee/network/SocketServer;->mTimeout:I

    return v0
.end method

.method public isHealthy()Z
    .locals 1

    .prologue
    .line 119
    iget-object v0, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    if-nez v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method

.method public remove()V
    .locals 5

    .prologue
    .line 161
    :try_start_0
    iget-object v4, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-virtual {v4}, Ljava/util/HashMap;->entrySet()Ljava/util/Set;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .line 162
    .local v0, "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/lang/Thread;>;>;"
    :cond_0
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_2

    move-result v4

    if-nez v4, :cond_2

    .line 168
    .end local v0    # "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/lang/Thread;>;>;"
    :goto_1
    iget-object v4, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-virtual {v4}, Ljava/util/HashMap;->clear()V

    .line 170
    :try_start_1
    iget-object v4, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-virtual {v4}, Ljava/util/HashMap;->entrySet()Ljava/util/Set;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .line 171
    .local v1, "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/net/Socket;>;>;"
    :cond_1
    :goto_2
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    move-result v4

    if-nez v4, :cond_3

    .line 183
    .end local v1    # "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/net/Socket;>;>;"
    :goto_3
    iget-object v4, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-virtual {v4}, Ljava/util/HashMap;->clear()V

    .line 184
    return-void

    .line 163
    .restart local v0    # "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/lang/Thread;>;>;"
    :cond_2
    :try_start_2
    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/util/Map$Entry;

    invoke-interface {v4}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/Thread;
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_2

    .line 164
    .local v3, "thread":Ljava/lang/Thread;
    if-eqz v3, :cond_0

    goto :goto_0

    .line 172
    .end local v0    # "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/lang/Thread;>;>;"
    .end local v3    # "thread":Ljava/lang/Thread;
    .restart local v1    # "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/net/Socket;>;>;"
    :cond_3
    :try_start_3
    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/util/Map$Entry;

    invoke-interface {v4}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/net/Socket;
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_1

    .line 173
    .local v2, "socket":Ljava/net/Socket;
    if-eqz v2, :cond_1

    .line 175
    :try_start_4
    invoke-virtual {v2}, Ljava/net/Socket;->close()V
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_2

    .line 176
    :catch_0
    move-exception v4

    goto :goto_2

    .line 181
    .end local v1    # "iterator":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Ljava/lang/Long;Ljava/net/Socket;>;>;"
    .end local v2    # "socket":Ljava/net/Socket;
    :catch_1
    move-exception v4

    goto :goto_3

    .line 166
    :catch_2
    move-exception v4

    goto :goto_1
.end method

.method public remove(J)V
    .locals 4
    .param p1, "index"    # J

    .prologue
    .line 187
    :try_start_0
    iget-object v2, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/Thread;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_2

    .line 188
    .local v1, "thread":Ljava/lang/Thread;
    if-eqz v1, :cond_0

    .line 189
    const/4 v1, 0x0

    .line 193
    .end local v1    # "thread":Ljava/lang/Thread;
    :cond_0
    :goto_0
    iget-object v2, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    .line 195
    :try_start_1
    iget-object v2, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/net/Socket;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    .line 196
    .local v0, "socket":Ljava/net/Socket;
    if-eqz v0, :cond_1

    .line 198
    :try_start_2
    invoke-virtual {v0}, Ljava/net/Socket;->close()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_1

    .line 201
    :goto_1
    const/4 v0, 0x0

    .line 205
    .end local v0    # "socket":Ljava/net/Socket;
    :cond_1
    :goto_2
    iget-object v2, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    .line 206
    return-void

    .line 199
    .restart local v0    # "socket":Ljava/net/Socket;
    :catch_0
    move-exception v2

    goto :goto_1

    .line 203
    .end local v0    # "socket":Ljava/net/Socket;
    :catch_1
    move-exception v2

    goto :goto_2

    .line 191
    :catch_2
    move-exception v2

    goto :goto_0
.end method

.method public run()V
    .locals 10

    .prologue
    const/4 v9, 0x1

    .line 51
    :try_start_0
    new-instance v5, Ljava/net/ServerSocket;

    iget-object v6, p0, Lrexsee/network/SocketServer;->mLocalInetSocketAddress:Ljava/net/InetSocketAddress;

    invoke-virtual {v6}, Ljava/net/InetSocketAddress;->getPort()I

    move-result v6

    iget v7, p0, Lrexsee/network/SocketServer;->mBacklog:I

    iget-object v8, p0, Lrexsee/network/SocketServer;->mLocalInetSocketAddress:Ljava/net/InetSocketAddress;

    invoke-virtual {v8}, Ljava/net/InetSocketAddress;->getAddress()Ljava/net/InetAddress;

    move-result-object v8

    invoke-direct {v5, v6, v7, v8}, Ljava/net/ServerSocket;-><init>(IILjava/net/InetAddress;)V

    iput-object v5, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    .line 52
    iget v5, p0, Lrexsee/network/SocketServer;->mTimeout:I

    if-lez v5, :cond_0

    iget-object v5, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    iget v6, p0, Lrexsee/network/SocketServer;->mTimeout:I

    invoke-virtual {v5, v6}, Ljava/net/ServerSocket;->setSoTimeout(I)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 57
    :cond_0
    :goto_0
    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnStarted:Lrexsee/network/SocketAbstractClass$SocketStartedListener;

    if-eqz v5, :cond_1

    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnStarted:Lrexsee/network/SocketAbstractClass$SocketStartedListener;

    iget-object v6, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    invoke-virtual {v5, v6, v9}, Lrexsee/network/SocketAbstractClass$SocketStartedListener;->run(Ljava/lang/String;Z)V

    .line 58
    :cond_1
    :goto_1
    iget-object v5, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    if-nez v5, :cond_3

    .line 101
    :cond_2
    :goto_2
    return-void

    .line 53
    :catch_0
    move-exception v5

    move-object v0, v5

    .line 54
    .local v0, "e":Ljava/lang/Exception;
    invoke-virtual {p0}, Lrexsee/network/SocketServer;->close()V

    .line 55
    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnFailed:Lrexsee/network/SocketAbstractClass$SocketFailedListener;

    if-eqz v5, :cond_0

    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnFailed:Lrexsee/network/SocketAbstractClass$SocketFailedListener;

    iget-object v6, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    invoke-virtual {v0}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v5, v6, v9, v7}, Lrexsee/network/SocketAbstractClass$SocketFailedListener;->run(Ljava/lang/String;ZLjava/lang/String;)V

    goto :goto_0

    .line 59
    .end local v0    # "e":Ljava/lang/Exception;
    :cond_3
    const/4 v4, 0x0

    .line 61
    .local v4, "waitingSocket":Ljava/net/Socket;
    :try_start_1
    iget-object v5, p0, Lrexsee/network/SocketServer;->mServerSocket:Ljava/net/ServerSocket;

    invoke-virtual {v5}, Ljava/net/ServerSocket;->accept()Ljava/net/Socket;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    move-result-object v4

    .line 67
    if-eqz v4, :cond_1

    .line 68
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v5

    invoke-static {v5, v6}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    .line 69
    .local v1, "index":Ljava/lang/Long;
    move-object v2, v4

    .line 70
    .local v2, "socket":Ljava/net/Socket;
    new-instance v3, Lrexsee/network/SocketServer$1;

    invoke-direct {v3, p0, v2, v1}, Lrexsee/network/SocketServer$1;-><init>(Lrexsee/network/SocketServer;Ljava/net/Socket;Ljava/lang/Long;)V

    .line 95
    .local v3, "thread":Ljava/lang/Thread;
    iget-object v5, p0, Lrexsee/network/SocketServer;->mReadingThreads:Ljava/util/HashMap;

    invoke-virtual {v5, v1, v3}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 96
    iget-object v5, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-virtual {v5, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 97
    invoke-virtual {v3}, Ljava/lang/Thread;->start()V

    .line 98
    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnConnected:Lrexsee/network/SocketAbstractClass$SocketConnectedListener;

    if-eqz v5, :cond_1

    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnConnected:Lrexsee/network/SocketAbstractClass$SocketConnectedListener;

    iget-object v6, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    invoke-virtual {v1}, Ljava/lang/Long;->longValue()J

    move-result-wide v7

    invoke-virtual {v5, v6, v7, v8}, Lrexsee/network/SocketAbstractClass$SocketConnectedListener;->run(Ljava/lang/String;J)V

    goto :goto_1

    .line 62
    .end local v1    # "index":Ljava/lang/Long;
    .end local v2    # "socket":Ljava/net/Socket;
    .end local v3    # "thread":Ljava/lang/Thread;
    :catch_1
    move-exception v5

    move-object v0, v5

    .line 63
    .restart local v0    # "e":Ljava/lang/Exception;
    invoke-virtual {p0}, Lrexsee/network/SocketServer;->close()V

    .line 64
    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnFailed:Lrexsee/network/SocketAbstractClass$SocketFailedListener;

    if-eqz v5, :cond_2

    iget-object v5, p0, Lrexsee/network/SocketServer;->mOnFailed:Lrexsee/network/SocketAbstractClass$SocketFailedListener;

    iget-object v6, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    invoke-virtual {v0}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v5, v6, v9, v7}, Lrexsee/network/SocketAbstractClass$SocketFailedListener;->run(Ljava/lang/String;ZLjava/lang/String;)V

    goto :goto_2
.end method

.method public setListeners(Lrexsee/network/SocketAbstractClass$SocketStartedListener;Lrexsee/network/SocketAbstractClass$SocketFailedListener;Lrexsee/network/SocketAbstractClass$SocketConnectedListener;Lrexsee/network/SocketAbstractClass$SocketLostListener;Lrexsee/network/SocketAbstractClass$SocketDataListener;Lrexsee/network/SocketAbstractClass$SocketDataListener;)V
    .locals 0
    .param p1, "started"    # Lrexsee/network/SocketAbstractClass$SocketStartedListener;
    .param p2, "failed"    # Lrexsee/network/SocketAbstractClass$SocketFailedListener;
    .param p3, "connected"    # Lrexsee/network/SocketAbstractClass$SocketConnectedListener;
    .param p4, "lost"    # Lrexsee/network/SocketAbstractClass$SocketLostListener;
    .param p5, "read"    # Lrexsee/network/SocketAbstractClass$SocketDataListener;
    .param p6, "write"    # Lrexsee/network/SocketAbstractClass$SocketDataListener;

    .prologue
    .line 111
    iput-object p1, p0, Lrexsee/network/SocketServer;->mOnStarted:Lrexsee/network/SocketAbstractClass$SocketStartedListener;

    .line 112
    iput-object p2, p0, Lrexsee/network/SocketServer;->mOnFailed:Lrexsee/network/SocketAbstractClass$SocketFailedListener;

    .line 113
    iput-object p3, p0, Lrexsee/network/SocketServer;->mOnConnected:Lrexsee/network/SocketAbstractClass$SocketConnectedListener;

    .line 114
    iput-object p4, p0, Lrexsee/network/SocketServer;->mOnLost:Lrexsee/network/SocketAbstractClass$SocketLostListener;

    .line 115
    iput-object p5, p0, Lrexsee/network/SocketServer;->mOnRead:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    .line 116
    iput-object p6, p0, Lrexsee/network/SocketServer;->mOnWrite:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    .line 117
    return-void
.end method

.method public write(J[B)Z
    .locals 7
    .param p1, "index"    # J
    .param p3, "bytes"    # [B

    .prologue
    const/4 v6, 0x0

    .line 227
    iget-object v3, p0, Lrexsee/network/SocketServer;->mSockets:Ljava/util/HashMap;

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/net/Socket;

    .line 228
    .local v2, "socket":Ljava/net/Socket;
    if-nez v2, :cond_0

    move v3, v6

    .line 237
    :goto_0
    return v3

    .line 230
    :cond_0
    :try_start_0
    invoke-virtual {v2}, Ljava/net/Socket;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v1

    .line 231
    .local v1, "outputStream":Ljava/io/OutputStream;
    invoke-virtual {v1, p3}, Ljava/io/OutputStream;->write([B)V

    .line 232
    iget-object v3, p0, Lrexsee/network/SocketServer;->mOnWrite:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    if-eqz v3, :cond_1

    iget-object v3, p0, Lrexsee/network/SocketServer;->mOnWrite:Lrexsee/network/SocketAbstractClass$SocketDataListener;

    iget-object v4, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    invoke-virtual {v3, v4, p1, p2, p3}, Lrexsee/network/SocketAbstractClass$SocketDataListener;->run(Ljava/lang/String;J[B)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 233
    :cond_1
    const/4 v3, 0x1

    goto :goto_0

    .line 234
    .end local v1    # "outputStream":Ljava/io/OutputStream;
    :catch_0
    move-exception v3

    move-object v0, v3

    .line 235
    .local v0, "e":Ljava/lang/Exception;
    invoke-virtual {p0}, Lrexsee/network/SocketServer;->close()V

    .line 236
    iget-object v3, p0, Lrexsee/network/SocketServer;->mOnLost:Lrexsee/network/SocketAbstractClass$SocketLostListener;

    if-eqz v3, :cond_2

    iget-object v3, p0, Lrexsee/network/SocketServer;->mOnLost:Lrexsee/network/SocketAbstractClass$SocketLostListener;

    iget-object v4, p0, Lrexsee/network/SocketServer;->mServerId:Ljava/lang/String;

    invoke-virtual {v0}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v3, v4, p1, p2, v5}, Lrexsee/network/SocketAbstractClass$SocketLostListener;->run(Ljava/lang/String;JLjava/lang/String;)V

    :cond_2
    move v3, v6

    .line 237
    goto :goto_0
.end method
